<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        let nums = [1,5,3,2,4]
    var maxFrequency = function(nums, k) {
    let c = [];
    for(let i = 0;i<nums.length;i++){
        if(nums[i]<k)
        c[i] = k - nums[i]
        else
        c[i] = nums[i] - k
    }
    return c
};
let c = maxFrequency(nums,3)
console.log(c);
    </script>
</head>
<body>
    
</body>
</html>